package com.lovo.spring_check.bean;

import com.lovo.spring_check.groups.UserAddGroups;
import com.lovo.spring_check.groups.UserUpdateGroups;

import javax.validation.constraints.AssertTrue;
import javax.validation.constraints.Email;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;

public class UserBean {
    private int id;
    @NotBlank(message = "用户名不能为空",groups = UserAddGroups.class)
    private String userName;
    @NotEmpty(message = "密码不能为空",groups = UserAddGroups.class)
    private String passWord;
    @Email(message = "邮箱格式不正确",groups = UserUpdateGroups.class)
    @NotBlank(message = "邮箱不能为空",groups = {UserUpdateGroups.class,UserAddGroups.class})
    private String email;
    @AssertTrue(message = "性别只能是男性")
    private boolean sex;

    public UserBean() {
    }

    public UserBean(int id, String userName, String passWord, String email) {
        this.id = id;
        this.userName = userName;
        this.passWord = passWord;
        this.email = email;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getUserName() {
        return userName;
    }

    public void setUserName(String userName) {
        this.userName = userName;
    }

    public String getPassWord() {
        return passWord;
    }

    public void setPassWord(String passWord) {
        this.passWord = passWord;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public boolean isSex() {
        return sex;
    }

    public void setSex(boolean sex) {
        this.sex = sex;
    }

    @Override
    public String toString() {
        return "UserBean{" +
                "id=" + id +
                ", userName='" + userName + '\'' +
                ", passWord='" + passWord + '\'' +
                ", email='" + email + '\'' +
                ", sex=" + sex +
                '}';
    }
}
